//
//  WBNologonView.swift
//  SinaWB
//
//  Created by 财神软件 on 17/2/10.
//  Copyright © 2017年 财神软件. All rights reserved.
//

import UIKit

class WBNologonView: UIView {
    lazy var bgimageView = UIImageView.init(image: UIImage.init(named: ""))
    lazy var imageView = UIImageView.init(image: UIImage.init(named: "newuser_card_icon_07_default"))
    lazy var logonbutton : UIButton = {
        let button = UIButton.init()
        button.setTitle("登录", for: .normal)
        button.setTitleColor(UIColor.red, for: .normal)
        button.sizeToFit()
        return button
        
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
//        addSubview(bgimageView)
        addSubview(imageView)
        addSubview(logonbutton)
        for obj in subviews {
            obj.translatesAutoresizingMaskIntoConstraints=false
        }
        addConstraint(NSLayoutConstraint.init(item: imageView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: imageView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0))
        
        addConstraint(NSLayoutConstraint.init(item: logonbutton, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: logonbutton, attribute: .top, relatedBy: .equal, toItem: imageView, attribute: .bottom, multiplier: 1.0, constant: 100))
        startAnimation()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func startAnimation(){
        let anim = CABasicAnimation.init(keyPath: "transform.rotation")
        anim.toValue=2*M_PI
        anim.repeatCount=MAXFLOAT
        anim.duration=10
        anim.isRemovedOnCompletion=false
        imageView.layer.add(anim, forKey: nil)
        
    }
}
